package com.niit.spark.sql.test

import org.apache.spark.sql.functions.desc
import org.apache.spark.sql.{DataFrame, SparkSession}

/**
 * Date:2025/5/16
 * Author：Ys
 * Description:
 */
object RenameColumn {

  def main(args: Array[String]): Unit = {
    val spark: SparkSession = SparkSession.builder().appName("RenameColumn").master("local[*]").getOrCreate()
    spark.sparkContext.setLogLevel("ERROR")
    val df: DataFrame = spark.read.option("header", "true").csv("input/sql/employees.csv")

    //重命名列  第一个参数 旧列名   第二个参数 新列名
    df.withColumnRenamed("name","full_name").show()

    spark.stop()

  }

}
